package LeetCode.leetcode;

/**
 * 反转字符串
 * @author: leiwenkang02@meituan.com
 * @date: 2018/8/23
 * @time: 12:32
 */
public class Test344反转字符串 {
    public static void main(String[] args) {
        String s = "A man, a plan, a canal: Panama";
        System.out.println(reverseString(s));

    }

    public static String reverseString(String s) {
        if (s == null || s.length() == 0) {
            return s;
        }
        char[] ch = s.toCharArray();
        int start = 0;
        int end = s.length() - 1;
        while (start < end) {
            char temp = ch[start];
            ch[start] = ch[end];
            ch[end] = temp;
            start++;
            end--;
        }
        return new String(ch);

    }
}
